% gets the result for the main table of the paper

    function [CE_N_man,CE_ST_man,CE_PKH_man,CE_NBNS_man,CE_HHW_man,Cg1] = analysis_main(Wi,CAPH,MU,Ppaid_N,Ppaid_spot,...
        Ppaid_pauly,Ppaid_spot_mean,iX,Nstates,rho,gamma,nInd,T,tolFP,maxreps)
  
    % welfare of german contracts without deductible
    CE_N_man = Welfare_4(Wi,Ppaid_N,0,gamma,iX,rho,Nstates);
    % welfare of short term contracts without deductible
    CE_ST_man = Welfare_4(Wi,Ppaid_spot,0,gamma,iX,rho,Nstates);
    % welfare of pauly contracts without deductible
    CE_PKH_man = Welfare_4(Wi,Ppaid_pauly,0,gamma,iX,rho,Nstates);
    % welfare of NBNS benchmark
    Ppaid_NBNS = repmat(Ppaid_spot_mean,1,nInd);
    CE_NBNS_man = Welfare_4(Wi,Ppaid_NBNS,0,gamma,iX,rho,Nstates);
    
    %HHW - simulated welfare
    Y1 = Wi(:,1);
    Cg1 = HHW_cg(Y1,MU,CAPH,Nstates,rho,T,tolFP,maxreps);
    C = Consumption_HHW(Cg1,iX);
    u = -1/gamma*exp(-gamma*1000*C);
    Num = mean(sum(u.*(iX~=(Nstates+1)).*power(rho,(1:T)-1)',1));
    Den = mean(sum((iX~=(Nstates+1)).*power(rho,(1:T)-1)',1));    
    CE_HHW_man = -log(-gamma*Num/Den)/gamma;

    
    end
           
    